﻿<UserControl x:Class="BassTrainer.UI.WPF.VisualSettings.VisualSettings"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:wpfExtensions="clr-namespace:WpfExtensions;assembly=WpfExtensions"
             mc:Ignorable="d" Height="520" Width="490">
    <UserControl.Resources>
        <SolidColorBrush x:Key="CorrectValueBrush" Color="White" />
        <SolidColorBrush x:Key="WrongValueBrush" Color="Red" />
        <wpfExtensions:EnumBooleanConverter x:Key="enumBooleanConverter" />
    </UserControl.Resources>

    <Grid x:Name="MainGrid">
        <Grid.ColumnDefinitions>
            <ColumnDefinition />
            <ColumnDefinition />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="3*"/>
            <RowDefinition Height="3*"/>
            <RowDefinition Height="3*"/>
            <RowDefinition Height="*"/>
            <RowDefinition />
        </Grid.RowDefinitions>
        <GroupBox Header="Rectangle presets" Grid.ColumnSpan="2" Grid.RowSpan="2">
            <Grid Name="NotesOnFretBoard">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="3*" />
                    <RowDefinition />
                    <RowDefinition Height="3*" />
                    <RowDefinition />
                </Grid.RowDefinitions>

                <Canvas Grid.Column="0" Grid.Row="0" Name="BordersArea1"
                        Background="BurlyWood" Margin="5,5,5,5" />
                <Canvas Grid.Column="1" Grid.Row="0" x:Name="BordersArea2"
                        Background="BurlyWood" Margin="5,5,5,5" />
                <Canvas Grid.Column="2" Grid.Row="0" x:Name="BordersArea3"
                        Background="BurlyWood" Margin="5,5,5,5" />

                <RadioButton Grid.Column="0" Grid.Row="1" Name="CorrectRadioButton0" GroupName="CorrecRect"
                             HorizontalAlignment="Center"
                             VerticalAlignment="Center"
                             IsChecked="{Binding Path=CorrectPreset, Converter={StaticResource enumBooleanConverter}, ConverterParameter=First}" />
                <RadioButton Grid.Column="1" Grid.Row="1" Name="CorrectRadioButton1" GroupName="CorrecRect"
                             HorizontalAlignment="Center"
                             VerticalAlignment="Center"
                             IsChecked="{Binding Path=CorrectPreset, Converter={StaticResource enumBooleanConverter}, ConverterParameter=Second}" />

                <RadioButton Grid.Column="2" Grid.Row="1" Name="CorrectRadioButton2" GroupName="CorrecRect"
                             HorizontalAlignment="Center"
                             VerticalAlignment="Center"
                             IsChecked="{Binding Path=CorrectPreset, Converter={StaticResource enumBooleanConverter}, ConverterParameter=Third}" />

                <Canvas Grid.Column="0" Grid.Row="2" x:Name="BordersArea4" Background="BurlyWood" Margin="5,5,5,5" />
                <Canvas Grid.Column="1" Grid.Row="2" x:Name="BordersArea5" Background="BurlyWood" Margin="5,5,5,5" />
                <Canvas Grid.Column="2" Grid.Row="2" x:Name="BordersArea6" Background="BurlyWood" Margin="5,5,5,5" />

                <RadioButton Name="WrongRadioButton0" GroupName="WrongRect" HorizontalAlignment="Center"
                             VerticalAlignment="Center" Grid.Column="0" Grid.Row="3"
                             IsChecked="{Binding Path=WrongPreset, Converter={StaticResource enumBooleanConverter}, ConverterParameter=First}" />
                <RadioButton Name="WrongRadioButton1" GroupName="WrongRect" HorizontalAlignment="Center"
                             VerticalAlignment="Center" Grid.Column="1" Grid.Row="3"
                             IsChecked="{Binding Path=WrongPreset, Converter={StaticResource enumBooleanConverter}, ConverterParameter=Second}" />
                <RadioButton Name="WrongRadioButton2" GroupName="WrongRect" HorizontalAlignment="Center"
                             VerticalAlignment="Center" Grid.Column="2" Grid.Row="3"
                             IsChecked="{Binding Path=WrongPreset, Converter={StaticResource enumBooleanConverter}, ConverterParameter=Third}" />
            </Grid>
        </GroupBox>

        <GroupBox Grid.Column="2" Grid.Row="0" Header="Note Text"
                  VerticalAlignment="Top">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition />
                </Grid.RowDefinitions>

                <Label Grid.Column="0" Grid.Row="0" Content="Font Family:" HorizontalAlignment="Right" />
                <ComboBox Grid.Column="1" Grid.Row="0" Name="FontFamilyComboBox"
                          ItemsSource="{Binding AvailableFontFamilies}"
                          SelectedItem="{Binding FontFamilySelectedItem}" />
                <Label Grid.Column="0" Grid.Row="1" Content="Font Size:" HorizontalAlignment="Right" />
                <TextBox Grid.Column="1" Grid.Row="1" ToolTipService.IsEnabled="False" Name="FontSizeTextBox"
                         MaxLength="2" TextWrapping="Wrap">
                    <TextBox.Text>
                        <Binding Path="FontSize" UpdateSourceTrigger="PropertyChanged">
                            <Binding.ValidationRules>
                                <wpfExtensions:IntegerRangeValidationRule Min="1" Max="30" />
                            </Binding.ValidationRules>
                        </Binding>
                    </TextBox.Text>
                </TextBox>
            </Grid>
        </GroupBox>
        <GroupBox Header="Show" Grid.Column="2" Grid.Row="1">
            <StackPanel>
                <RadioButton Name="ShowSharps" GroupName="Show" Content="Only Sharps"
                             IsChecked="{Binding IsSharpStyleShown}" />
                <RadioButton Name="ShowBemol" GroupName="Show" Content="OnlyFlats"
                             IsChecked="{Binding IsFlatStyleShown}" />
                <RadioButton Name="ShowMixed" GroupName="Show" Content="Mixed"
                             IsChecked="{Binding IsMixedStyleShown}" />
            </StackPanel>
        </GroupBox>

        <GroupBox Header="Excercises" Grid.Column="0" Grid.Row="2" Grid.RowSpan="2">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition Width="2*" />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                </Grid.RowDefinitions>
                <Label Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="0" Content="Attempts:" HorizontalAlignment="Left" />
                <TextBox Grid.Column="0" Grid.Row="1" ToolTipService.IsEnabled="False" Name="NoOfTries"
                         MaxLength="5"
                         TextWrapping="Wrap">
                    <TextBox.Text>
                        <Binding Path="NoOfTries" UpdateSourceTrigger="PropertyChanged">
                            <Binding.ValidationRules>
                                <wpfExtensions:IntegerRangeValidationRule Min="1" Max="10" />
                            </Binding.ValidationRules>
                        </Binding>
                    </TextBox.Text>

                </TextBox>
                <Label Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="2" Content="Show last hit for [s]:"
                       HorizontalAlignment="Left" />
                <TextBox Grid.Column="0" Grid.Row="3" ToolTipService.IsEnabled="False" Name="ShowLastHitFor"
                         MaxLength="5"
                         TextWrapping="Wrap">
                    <TextBox.Text>
                        <Binding Path="ShowLastHitFor" UpdateSourceTrigger="PropertyChanged">
                            <Binding.ValidationRules>
                                <wpfExtensions:IntegerRangeValidationRule Min="0" Max="10" />
                            </Binding.ValidationRules>
                        </Binding>
                    </TextBox.Text>
                </TextBox>
                <Label Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="4" Content="Show Correct Anwser:"
                       HorizontalAlignment="Left" />
                <CheckBox Grid.Column="0" Grid.Row="5" ToolTipService.IsEnabled="False"
                          IsChecked="{Binding IsShowCorrectAnwserSelected}"
                          HorizontalAlignment="Center" VerticalAlignment="Center" />
            </Grid>
        </GroupBox>


        <Grid Grid.Column="1" Grid.Row="4"  Grid.ColumnSpan="2" Grid.IsSharedSizeScope="True" >
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="100" SharedSizeGroup="buttons" />
                <ColumnDefinition Width="100" SharedSizeGroup="buttons" />
            </Grid.ColumnDefinitions>
            <Button Name="Apply" Content="Apply"  Grid.Column="0" Command="{Binding ApplySettingsCommand}">
                <Button.Resources>
                    <ResourceDictionary>
                        <ResourceDictionary.MergedDictionaries>
                            <ResourceDictionary
                                Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.Buttons.xaml" />
                        </ResourceDictionary.MergedDictionaries>
                    </ResourceDictionary>
                </Button.Resources>
                <Button.Style>
                    <Style BasedOn="{StaticResource MetroButton}" TargetType="{x:Type Button}">
                        <Setter Property="IsEnabled" Value="False" />
                        <Style.Triggers>
                            <MultiDataTrigger>
                                <MultiDataTrigger.Conditions>
                                    <Condition Binding="{Binding Path=(Validation.HasError), ElementName=NoOfTries}"
                                               Value="False" />
                                    <Condition Binding="{Binding Path=(Validation.HasError), ElementName=ShowLastHitFor}"
                                               Value="False" />
                                    <Condition Binding="{Binding Path=(Validation.HasError), ElementName=FontSizeTextBox}"
                                               Value="False" />
                                </MultiDataTrigger.Conditions>
                                <Setter Property="IsEnabled" Value="True" />
                            </MultiDataTrigger>
                        </Style.Triggers>
                    </Style>
                </Button.Style>
            </Button>
            <Button Content="Revert" Grid.Column="1" Command="{Binding RevertSettingsCommand}"/>
        </Grid>
    </Grid>
</UserControl>